package tomsung.cloud.agdc.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tomsung.cloud.agdc.bean.Device;
import tomsung.cloud.agdc.dao.DeviceMapper;

@Service("DeviceService")
public class DeviceService {

	
	@Autowired
	DeviceMapper deviceMapper;
	
	public int createDevice(Device record)
	{
		return deviceMapper.insertSelective(record);
	}
	

	public List<Device> selectByGreenhouseIds(List<Integer> greenhouseIds) {
		return deviceMapper.selectByGreenhouseIds(greenhouseIds);
	}
	
	public List<Device> selectDevicesByDeviceType(Integer deviceType)
	{
		return deviceMapper.selectDevicesByDeviceType(deviceType);
	}
	
	public List<Device> selectDevicesByDeviceTypeInGreenhouse(Integer greenhouseId, Integer deviceType)
	{
		return deviceMapper.selectDevicesByDeviceTypeInGreenhouse(greenhouseId, deviceType);
	}
	
	public List<Device> selectDevicesByGreenhouseID(Integer greenhouseID)
	{
		return deviceMapper.selectDevicesByGreenhouseID(greenhouseID);
	}
	
	public List<Device> selectDevicesBySystemId(Long systemId)
	{
		return deviceMapper.selectDevicesBySystemId(systemId);
	}
	
	public Device selectDeviceBySystemId(Long systemId, Integer ctrlid, Integer deviceid, Integer devicetype)
	{
		return deviceMapper.selectByPrimaryKey(systemId,ctrlid, deviceid,devicetype);
	}

}
